package com.lantu.draw.login;

import org.apache.commons.codec.digest.DigestUtils;

public class MD5Encrypt {
	//private static final String MD5_PREFIX = "http://draw.lantu.com";

	private static final ThreadLocal<MD5Encrypt> local = new ThreadLocal<MD5Encrypt>();

	private MD5Encrypt() {
		super();
	}

	public static MD5Encrypt getEncrypt() {
		MD5Encrypt encrypt = local.get();
		if (encrypt == null) {
			encrypt = new MD5Encrypt();
			local.set(encrypt);
		}
		return encrypt;
	}

	public static String encode(String s) {
		if (s == null) {
			return null;
		}
		//return DigestUtils.md5Hex(MD5_PREFIX + s);
		return DigestUtils.md5Hex(s);
	}

	public static void main(String[] args) {
		String passwd = "admin";
		System.out.println(passwd + " 加密后为： " + encode(passwd));

	}
}
